/*
 * @Author: Jiraiya
 * @Date: 2020-03-31 14:21:07
 * @LastEditors: Jiraiya
 * @LastEditTime: 2020-06-09 19:05:35
 * @Description: 
 */

const path = require('path');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
const DllReferencePlugin = require('webpack/lib/DllReferencePlugin');
const BundleAnalyzerPlugn = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');

const moduleName = 'txt';
const entryList = {
    'loadable': path.resolve(__dirname, '../code/loadable/src/index.js'),
    // 'redux': path.resolve(__dirname, '../code/redux/index.js'),
    'txt': path.resolve(__dirname, './loader/1.txt')
}
const entry = {}; entry[moduleName] = entryList[moduleName];



const ConsoleStartBuild = require('./plugin/ConsoleStartBuild');
module.exports = {
    mode: 'development',
    entry,
    output: {
        filename: '[name].js',
        chunkFilename: '[name].lazy.js',
        path: path.resolve(__dirname, '../dist'),
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                use: [
                    'babel-loader',
                 ],
            },
            {
                test: /\.txt$/,
                use: [

                    'babel-loader',
                    {
                        loader: path.resolve(__dirname, './loader/ww-loader'),
                        options: {
                            a:1,
                            b:2,
                        }
                    }
                ]
            }
        ],
    },
    plugins: [
        new DllReferencePlugin({
            manifest: require('../dist/common.manifest.json'),
        }),
        new HtmlWebpackPlugin({
            template: 'index.html',
            filename: 'index.html',
            dll:'common.dll.js',
        }),
        new ConsoleStartBuild({a: 1}),
        // new AddAssetHtmlPlugin([
        //     { filepath: require.resolve('../dist/common.dll.js') },
        // ])
    ],
    devtool: 'source-map',
};
